<template>
  <el-select v-model="value" v-bind="$attrs">
    <el-option v-for="opt in opts" :key="opt.value" :value="opt.value" :label="opt.label"></el-option>
  </el-select>
</template>

<script>
export default {
  name: "YmRelation",
  props: {
    url: {
      type: String,
      default: null
    },
    value: {
      default: null
    }
  },
  computed: {
    value_: {
      get () {
        return this.value
      },
      set (v) {
        this.$emit('input', v)
      }
    }
  },
  data () {
    return {
      opts: []
    }
  },
  async created() {
    if (this.url) this.opts = await this.$http.Get(this.url)
  },
  watch: {
    async url () {
      if (this.url) this.opts = await this.$http.Get(this.url)
    }
  }
}
</script>

<style scoped>

</style>
